<template>
	<sw-common-frame :loading="loading">
		<template slot="button">
			<el-button type="primary" size="small" icon="el-icon-plus" @click="handleOpenDialog()">新建</el-button>
		</template>
		<el-form slot="query" size="small" inline>
			<el-form-item>
				<el-input placeholder="请输入按钮名称" v-model="queryData.name" clearable></el-input>
			</el-form-item>
			<el-form-item>
				<sw-dict-select v-model="queryData.type" dict-name="DISK_ROLE_BUTTON_TYPE" clearable placeholder="按钮类别" style="width: 120px"></sw-dict-select>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" icon="el-icon-search" @click="queryTableData()">搜索</el-button>
			</el-form-item>
		</el-form>
		<template slot="table">
			<el-table size="medium" :data="tableData" stripe height="100%">
				<el-table-column label="名称" prop="name" min-width="200"></el-table-column>
				<el-table-column label="类别" min-width="100" :formatter="returnButtonType"></el-table-column>
				<el-table-column label="描述" prop="content" min-width="160"></el-table-column>
				<el-table-column label="创建人" prop="createName" min-width="100"></el-table-column>
				<el-table-column label="创建时间" prop="createTime" min-width="160"></el-table-column>
				<el-table-column label="操作" width="90">
					<template slot-scope="{ row }">
						<el-button size="medium" type="text" @click="handleOpenDialog(row.id)">编辑</el-button>
						<el-button size="medium" type="text" @click="handleDeleteData(row)">删除</el-button>
					</template>
				</el-table-column>
			</el-table>
		</template>
		<template slot="page">
			<sw-pagination :total="dataCount" :page.sync="queryData.page" :limit.sync="queryData.limit" @change="queryTableData()"></sw-pagination>
		</template>
		<form-dialog v-model="formDialog" :data-id="dataId" @refresh="queryTableData()"></form-dialog>
	</sw-common-frame>
</template>

<script>
import formDialog from './form';
import listMixins from '@/mixins/listMixins';
import { getLibraryButtonList, deleteLibraryButton } from '@/api/platform/tbRoleButton';
export default {
	mixins: [listMixins],
	components: { formDialog },
	data() {
		return {};
	},
	computed: {
		listFunction() {
			return eval(getLibraryButtonList);
		},
		deleteFunction() {
			return eval(deleteLibraryButton);
		}
	},
	methods: {
		//格式化按钮类型
		returnButtonType(data) {
			let list = this.dictEnums['DISK_ROLE_BUTTON_TYPE'];
			let info = list.find((item) => item.value === data.type);
			return !info ? '--' : info.msg;
		}
	}
};
</script>
<style lang="scss" scoped></style>
